/**
 * 遍历树
 * @param {Array} list 
 * @param {Object} options
 * @param {Function} options.resolveNodeListFn -遍历每一层级节点时会调用该函数，接收两个参数：list -层级的数组；level -层级
 * @param {Function} options.resolveNodeFn -遍历每一个节点时会调用该函数，接收两个参数：item -当前遍历的节点；level -层级
 * @param {Number} level 
 * @returns 
 */
export function walkTree(list, options = {}, level = 1){
    if(!Array.isArray(list)) return
    const { resolveNodeFn, resolveNodeListFn } = options
    const listFlag = resolveNodeListFn ? !resolveNodeListFn(list, level) : true
    listFlag && list.forEach(item => {
        const continueFlag = resolveNodeFn ? !resolveNodeFn(item, level) : true
        const childLevel = level + 1
        continueFlag && walkTree(item.children, options, childLevel)
    })
}